using DevExpress.XtraEditors;
using DevExpress.XtraEditors.DXErrorProvider;
using Common.Class;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace Common.Base
{
	public class XucBaseB : XucBase
	{
		private IContainer components = null;
		protected DXErrorProvider Err;
		protected PanelControl plBottom;
		protected XucBarB ucBarB;
		public XucBarB Bar
		{
			get
			{
				return this.ucBarB;
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			this.Err = new DXErrorProvider(this.components);
			this.plBottom = new PanelControl();
			this.ucBarB = new XucBarB();
			((ISupportInitialize)this.Err).BeginInit();
			((ISupportInitialize)this.plBottom).BeginInit();
			this.plBottom.SuspendLayout();
			base.SuspendLayout();
			this.Err.ContainerControl = this;
			this.plBottom.Controls.Add(this.ucBarB);
			this.plBottom.Location = new Point(52, 445);
			this.plBottom.Name = "plBottom";
			this.plBottom.Size = new Size(564, 31);
			this.plBottom.TabIndex = 0;
			this.ucBarB.Dock = DockStyle.Fill;
			this.ucBarB.IsClose = CloseOrNew.None;
			this.ucBarB.Location = new Point(2, 2);
			this.ucBarB.Name = "ucBarB";
			this.ucBarB.Size = new Size(560, 27);
			this.ucBarB.Status = Actions.None;
			this.ucBarB.TabIndex = 0;
			this.ucBarB.Title = "";
			base.AutoScaleDimensions = new SizeF(6f, 13f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.Controls.Add(this.plBottom);
			this.DoubleBuffered = true;
			base.Name = "XucBaseB";
			base.Size = new Size(731, 498);
			((ISupportInitialize)this.Err).EndInit();
			((ISupportInitialize)this.plBottom).EndInit();
			this.plBottom.ResumeLayout(false);
			base.ResumeLayout(false);
		}
		public XucBaseB()
		{
			this.InitializeComponent();
			this.Init();
		}
		protected override bool ProcessDialogKey(Keys keyData)
		{
			bool result;
			if (keyData <= (Keys)131156)
			{
				if (keyData <= Keys.F12)
				{
					if (keyData == Keys.Escape)
					{
						this.EscapeExecute();
						result = true;
						return result;
					}
					switch (keyData)
					{
					case Keys.F1:
						this.F11Execute();
						result = true;
						return result;
					case Keys.F2:
						this.UcToolBarSaveClick(this);
						result = true;
						return result;
					case Keys.F3:
						this.F3Execute();
						result = true;
						return result;
					case Keys.F4:
						this.F4Execute();
						result = true;
						return result;
					case Keys.F5:
						this.F5Execute();
						result = true;
						return result;
					case Keys.F6:
						this.F9Execute();
						result = true;
						return result;
					case Keys.F7:
						this.F7Execute();
						result = true;
						return result;
					case Keys.F8:
						this.F8Execute();
						result = true;
						return result;
					case Keys.F9:
						this.F9Execute();
						result = true;
						return result;
					case Keys.F10:
						this.F10Execute();
						if (base.ParentForm != null)
						{
							base.ParentForm.Close();
						}
						result = true;
						return result;
					case Keys.F11:
						this.F11Execute();
						result = true;
						return result;
					case Keys.F12:
						this.F12Execute();
						result = true;
						return result;
					}
				}
				else
				{
					if (keyData == (Keys)65649)
					{
						this.UcToolBarSaveNewClick(this);
						result = true;
						return result;
					}
					switch (keyData)
					{
					case (Keys)131150:
						this.UcToolBarAddClick(this);
						result = true;
						return result;
					case (Keys)131152:
						this.UcToolBarPrintClick(this);
						result = true;
						return result;
					case (Keys)131155:
						this.UcToolBarSaveClick(this);
						result = true;
						return result;
					case (Keys)131156:
						this.UcToolBarAddClick(this);
						result = true;
						return result;
					}
				}
			}
			else
			{
				if (keyData <= (Keys)196691)
				{
					if (keyData == (Keys)131159)
					{
						this.UcToolBarSaveClick(this);
						result = true;
						return result;
					}
					if (keyData == (Keys)196691)
					{
						this.UcToolBarSaveNewClick(this);
						result = true;
						return result;
					}
				}
				else
				{
					if (keyData == (Keys)196695)
					{
						this.UcToolBarSaveNewClick(this);
						result = true;
						return result;
					}
					if (keyData == (Keys)262212)
					{
						result = true;
						return result;
					}
					if (keyData == (Keys)262232)
					{
						if (base.ParentForm != null)
						{
							base.ParentForm.Close();
						}
						result = true;
						return result;
					}
				}
			}
			base.NotSave = true;
			this.Bar.Bar.bbiSaveM.Enabled = true;
			result = false;
			return result;
		}
		public virtual void DisableControl(bool disable)
		{
		}
		public void Init()
		{
			this.ucBarB.AddClick += new ButtonClickEventHander(this.UcToolBarAddClick);
			this.ucBarB.SaveClick += new ButtonClickEventHander(this.UcToolBarSaveClick);
			this.ucBarB.SaveNewClick += new ButtonClickEventHander(this.UcToolBarSaveNewClick);
			this.ucBarB.CancleClick += new ButtonClickEventHander(this.UcToolBarCancleClick);
			this.ucBarB.PrintClick += new ButtonClickEventHander(this.UcToolBarPrintClick);
			this.ucBarB.CloseClick += new ButtonClickEventHander(this.UcToolBarCloseClick);
			this.ucBarB.DeleteClick += new ButtonClickEventHander(this.UcToolBarDeleteClick);
			this.ucBarB.ClearClick += new ButtonClickEventHander(this.UcToolBarClearClick);
			this.ucBarB.HistoryClick += new ButtonClickEventHander(this.UcToolBarHistoryClick);
			this.ucBarB.InventoryClick += new ButtonClickEventHander(this.UcToolBarInventoryClick);
			this.ucBarB.SelectAllClick += new ButtonClickEventHander(this.UcToolBarSelectAllClick);
			this.ucBarB.ExportClick += new ButtonClickEventHander(this.UcToolBarExportClick);
			this.ucBarB.CopyClick += new ButtonClickEventHander(this.UcBarBCopyClick);
			this.ucBarB.HelpClick += new ButtonClickEventHander(this.ucBarB_HelpClick);
		}
		private void ucBarB_HelpClick(object sender)
		{
			Process.Start("http://www.perfect.com.vn/huong-dan-su-dung-phan-mem-quan-ly-doanh-nghiep-perfect.erp.htm");
		}
		public virtual void Copy()
		{
		}
		private void UcBarBCopyClick(object sender)
		{
			this.Copy();
		}
		private void UcToolBarExportClick(object sender)
		{
			base.Export();
		}
		public virtual void SelectAll()
		{
		}
		private void UcToolBarSelectAllClick(object sender)
		{
			this.SelectAll();
		}
		public virtual void Inventory()
		{
		}
		private void UcToolBarInventoryClick(object sender)
		{
			this.Inventory();
		}
		public virtual void History()
		{
		}
		private void UcToolBarHistoryClick(object sender)
		{
			this.History();
		}
		private void UcToolBarClearClick(object sender)
		{
			this.DeleteAll();
		}
		public virtual void DeleteAll()
		{
		}
		public virtual void DeleteSelected()
		{
		}
		private void UcToolBarDeleteClick(object sender)
		{
			this.DeleteSelected();
		}
		private void UcToolBarCloseClick(object sender)
		{
			if (base.ParentForm != null)
			{
				base.ParentForm.Close();
			}
		}
		private void UcToolBarPrintClick(object sender)
		{
			this.Print();
		}
		public void Cancel()
		{
			this.MStatus = Actions.None;
			Cursor.Current = Cursors.Default;
			this.DisableControl(false);
			base.NotSave = false;
		}
		private void UcToolBarCancleClick(object sender)
		{
			this.Cancel();
		}
		private void UcToolBarSaveNewClick(object sender)
		{
			if (this.Save() == "OK")
			{
				this.UcToolBarAddClick(sender);
			}
		}
		private void UcToolBarSaveClick(object sender)
		{
			if (this.Bar.Bar.bbiSave.ImageIndex == this.Bar.Bar.bbiSaveNew.ImageIndex)
			{
				if (this.Save() == "OK")
				{
					this.UcToolBarAddClick(sender);
				}
			}
			else
			{
				this.Save();
			}
		}
		private void UcToolBarAddClick(object sender)
		{
			this.Clear();
			this.Add();
		}
		public void ProductAdd(object item)
		{
		}
		protected void DisableMenu(bool disable)
		{
			this.Bar.Bar.bbiDeleteAll.Enabled = !disable;
			this.Bar.Bar.bbiDelete.Enabled = !disable;
			this.Bar.Bar.bbiSelectAll.Enabled = !disable;
			this.Bar.Bar.bbiProduct.Enabled = !disable;
		}
		public virtual string UcSave()
		{
			return string.Empty;
		}
		public virtual string UcUpdate()
		{
			return string.Empty;
		}
		public virtual bool Check()
		{
			return true;
		}
		public string Save()
		{
			string result;
			if (!this.Check())
			{
				result = "";
			}
			else
			{
				if (this.MStatus == Actions.Add)
				{
					result = this.UcSave();
				}
				else
				{
					if (this.MStatus == Actions.Update)
					{
						this.UcUpdate();
					}
					result = "";
				}
			}
			return result;
		}
		public virtual void Print()
		{
		}
		public virtual void Add()
		{
		}
		protected virtual void F3Execute()
		{
		}
		protected void F4Execute()
		{
		}
		protected void F5Execute()
		{
		}
		protected void F7Execute()
		{
		}
		protected void F8Execute()
		{
		}
		protected void F9Execute()
		{
		}
		protected void F10Execute()
		{
		}
		protected void F11Execute()
		{
		}
		protected void F12Execute()
		{
		}
		protected void EscapeExecute()
		{
		}
	}
}
